package com.gin.no_gay_alliance.adpter.reply;

import android.content.Context;
import android.view.LayoutInflater;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.core.content.res.ResourcesCompat;

import com.gin.nga.response.alterlog.ReputationLog;
import com.gin.no_gay_alliance.R;
import com.gin.no_gay_alliance.adpter.base.BaseBindingRecyclerViewAdapter;
import com.gin.no_gay_alliance.databinding.ItemTextBinding;

import java.util.List;

/**
 * 操作日志适配器
 *
 * @author : ginstone
 * @version : v1.0.0
 * @since : 2023/9/6 14:26
 **/
public class OperationLogAdapter extends BaseBindingRecyclerViewAdapter<ItemTextBinding, ReputationLog> {
    public OperationLogAdapter(Context context) {
        super(context);
    }

    public OperationLogAdapter(@NonNull Context context, @NonNull List<ReputationLog> data) {
        super(context, data);
    }

    /**
     * 绑定数据
     *
     * @param holder
     * @param b        绑定对象
     * @param position 位置
     * @param item
     */
    @Override
    protected void onBindViewHolder(ViewHolder<ItemTextBinding> holder, @NonNull ItemTextBinding b, int position, ReputationLog item) {
        TextView tv = b.getRoot();
        tv.setText(item.getDescription());
        switch (item.getRate()) {
            case positive:
                tv.setTextColor(ResourcesCompat.getColor(context.getResources(), R.color.green, context.getTheme()));
                break;
            case negative:
                tv.setTextColor(ResourcesCompat.getColor(context.getResources(), R.color.red, context.getTheme()));
                break;
            case neutral:
                tv.setTextColor(ResourcesCompat.getColor(context.getResources(), R.color.yellow, context.getTheme()));
                break;
        }
    }

    @NonNull
    @Override
    protected ItemTextBinding buildBinding(LayoutInflater inflater) {
        return ItemTextBinding.inflate(inflater);
    }

    /**
     * @return 是否应用斑马纹配色
     */
    @Override
    protected boolean useZebraStripe() {
        return false;
    }
}
